package com.shaiMiMi;

import java.util.Vector;



public class ConnectInfo {
	public class ServerInfo{
		public String 	mServer = "192.168.0.4";
//		public String 	mServer = "115.47.10.88";
		public int		mServerPort = 45469;
	}

	private static ConnectInfo mConnectInfo = null;
	private ServerInfo 	mServerInfo = null;
	private boolean		mHaveConnected = false;
	private ZTcpSocketThread mTcpSocketThread = null;

	private Vector<ZTcpSocketThread> mTestServerSockVec = new Vector<ZTcpSocketThread>();

	private ConnectInfo(){

	}

	public static ConnectInfo GetInstance(){
		if (null == mConnectInfo) {
			mConnectInfo = new ConnectInfo();
		}

		return mConnectInfo;
	}

	public void Init(ZTcpSocketThread tcpSocketThread){
		mTcpSocketThread = tcpSocketThread;
	}

	public void InitTestServerContain() {
		if (null != mTcpSocketThread) {
			ZHelpThreadTool.PushThreadTask(new Runnable() {
				@Override
				public void run() {
					ZTcpSocketThread newSocketThread = null;

					for (int i = 0; i < 800; i++) {
						newSocketThread = new ZTcpSocketThread(mTcpSocketThread);
						mTestServerSockVec.add(newSocketThread);
						newSocketThread.start();
					}
				}
			});
		}
	}

	public void SendPack4TestServerContain(final ZPackage pack){
		ZHelpThreadTool.PushThreadTask(new Runnable() {
			@Override
			public void run() {
				for (int i = 0; i < mTestServerSockVec.size(); i++) {
					mTestServerSockVec.get(i).AppendPack(pack);
				}
			}
		});
	}

	public boolean IsTestMode(){
		return !mTestServerSockVec.isEmpty();
	}

	public ZTcpSocketThread GetTcpSocketThread(){
		return mTcpSocketThread;
	}

	public ZTcpSocketThread TestServerMaxContain(ZPackage pack){
		return mTcpSocketThread;
	}

	public ServerInfo GetServerInfo(){
		if (null == mServerInfo) {
			mServerInfo = new ServerInfo();
		}

		return mServerInfo;
	}

	public void SetConnected(boolean bHaveConnected) {
		mHaveConnected = bHaveConnected;
	}

	public boolean GetConnected() {
		return mHaveConnected;
	}
}

















